<template>
  <div
    :class="`bwy-btn${isDot ? '_dot' : ''} ${btnClass}`"
    :style="{
      ...parseStyle(btnStyle),
      '--color': color,
      padding:
        size == 'small'
          ? '8px 20px'
          : size == 'medium'
          ? '12px 28px'
          : '16px 36px'
    }"
  >
    <w-icon v-if="icon" :name="icon" :color="isDot ? color : `#fff`" :size="iconSize"/>
    <slot></slot>
    <div v-if="isDot" class="bwy-btn-mask"></div>
  </div>
</template>

<script setup>
import { parseStyle } from '@/common/index.js'
import WIcon from '../w-icon.vue'

const props = defineProps({
  // 是否空心
  isDot: {
    type: Boolean,
    default: false,
  },
  // 尺寸 small - 小号 medium - 中等 large - 大号
  size: {
    type: String,
    default: "small",
  },
  icon: {
    type: String,
    default: ''
  },
  iconSize : {
    type : String,
    default : '13px'
  },
  // 类名
  btnClass: {
    type: String,
    default: "",
  },
  // 颜色
  color: {
    type: String,
    default: "#1677ff",
  },
  // 内联样式
  btnStyle: {
    type: [Object, String],
    default: "",
  },
});
</script>

<style>
.bwy-btn {
  position: relative;
  background: var(--color);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: 0.3s ease-in-out;
  font-size: 16px;
  line-height: 16px;
  letter-spacing: 1px;
  color: #fff;
  display: flex;
  align-items: center;
}
.bwy-btn_dot {
  color: var(--color);
  display: flex;
  align-items: center;
  border: 1px solid var(--color);
  border-radius: 4px;
  font-size: 16px;
  line-height: 16px;
  letter-spacing: 1px;
  cursor: pointer;
  position: relative;
}
.bwy-btn:active {
  transform: scale(0.8);
}
.bwy-btn_dot:active {
  transform: scale(0.8);
}
.bwy-btn-mask {

  background: var(--color);
  opacity: 0.1;
  position: absolute;
  left: 0;
  top: 0;
}
</style>
